package com.myBlog.controller;

import com.myBlog.domain.ResponseResult;
import com.myBlog.domain.dto.LinkDTO;
import com.myBlog.domain.vo.PageVo;
import com.myBlog.service.LinkService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 友链
 */

@RestController
@RequestMapping("/content/link")
public class LinkController {
    @Resource
    private LinkService linkService;


    @GetMapping("/list")
    public ResponseResult<PageVo> list(Integer pageNum, Integer pageSize, LinkDTO linkDTO) {
        return linkService.list(pageNum, pageSize, linkDTO);
    }

    @GetMapping("{id}")
    public ResponseResult getLinkInfo(@PathVariable("id") Long linkId) {
        return linkService.getLinkInfo(linkId);
    }

    @PutMapping
    public ResponseResult updateLink(@RequestBody LinkDTO linkDTO) {
        return linkService.updateLink(linkDTO);
    }

    @PostMapping
    public ResponseResult addLink(@RequestBody LinkDTO linkDTO) {
        return linkService.addLink(linkDTO);
    }

    @DeleteMapping("{id}")
    public ResponseResult delete(@PathVariable("id") List<Long> ids) {
        return linkService.delete(ids);
    }
}
